condition on wait not applying accordingly